顯示圖像內部資訊
https://www.thepythoncode.com/article/extracting-image-metadata-in-python
安裝環境
pip3 install Pillow
載入函式庫
from PIL import Image
from PIL.ExifTags import TAGS
這個功能只能作用於JPEG檔案
Now this will only work on JPEG image files, take any image you took and test it for this tutorial (if you want to test on my image, you'll find it in the tutorial's repository):
imagename = "image.jpg"
image = Image.open(imagename)
exifdata = image.getexif()
for tag_id in exifdata:
tag = TAGS.get(tag_id, tag_id)
data = exifdata.get(tag_id)
if isinstance(data, bytes):
data = data.decode()
print(f"{tag:25}: {data}")